package com.lw.controller;

import com.lw.common.utils.ResultVo;
import com.mybatisflex.core.paginate.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.beans.factory.annotation.Autowired;
import com.lw.entity.TbUserInterface;
import com.lw.service.TbUserInterfaceService;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;

/**
 *  控制层。
 *
 * @author lw
 * @since 2025年04月29日 17:50:05
 */
@RestController
@Tag(name = "用户数据服务器接口绑定接口", description = "用户数据服务器接口绑定接口")
@RequestMapping("/tbUserInterface")
public class TbUserInterfaceController {

    @Autowired
    private TbUserInterfaceService tbUserInterfaceService;

    /**
     * 添加。
     *
     * @param tbUserInterface
     * @return {@code true} 添加成功，{@code false} 添加失败
     */
    @PostMapping("save")
    @Operation(summary = "保存")
    public ResultVo<Boolean> save(@RequestBody @Parameter(description = "") TbUserInterface tbUserInterface) {
        return ResultVo.success(tbUserInterfaceService.save(tbUserInterface));
    }

    /**
     * 根据主键删除。
     *
     * @param id 主键
     * @return {@code true} 删除成功，{@code false} 删除失败
     */
    @DeleteMapping("remove/{id}")
    @Operation(summary = "根据主键")
    public ResultVo<Boolean> remove(@PathVariable @Parameter(description = "主键") Integer id) {
        return ResultVo.success(tbUserInterfaceService.removeById(id));
    }

    /**
     * 根据主键更新。
     *
     * @param tbUserInterface
     * @return {@code true} 更新成功，{@code false} 更新失败
     */
    @PutMapping("update")
    @Operation(summary = "根据主键更新")
    public ResultVo<Boolean> update(@RequestBody @Parameter(description = "主键") TbUserInterface tbUserInterface) {
        return ResultVo.success(tbUserInterfaceService.updateById(tbUserInterface));
    }

    /**
     * 查询所有。
     *
     * @return 所有数据
     */
    @GetMapping("list")
    @Operation(summary = "查询所有")
    public ResultVo<List<TbUserInterface>> list() {
        return ResultVo.success(tbUserInterfaceService.list());
    }

    /**
     * 根据主键获取详细信息。
     *
     * @param id 主键
     * @return 详情
     */
    @GetMapping("getInfo/{id}")
    @Operation(summary = "根据主键获取")
    public ResultVo<TbUserInterface> getInfo(@PathVariable @Parameter(description = "主键") Integer id) {
        return ResultVo.success(tbUserInterfaceService.getById(id));
    }

    /**
     * 分页查询。
     *
     * @param page 分页对象
     * @return 分页对象
     */
    @GetMapping("page")
    @Operation(summary = "分页查询")
    public ResultVo<Page<TbUserInterface>> page(@Parameter(description = "分页信息") Page<TbUserInterface> page) {
        return ResultVo.success(tbUserInterfaceService.page(page));
    }

}
